package com.easybenefit.UUService;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.easybeanfit.UUService.commutill.UncaughtExceptionHandler;
import com.easybeanfit.UUService.config.UUConfig;
import com.umeng.socialize.PlatformConfig;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Andy on 2016/6/8.
 */
public class MyApplication extends Application {
    public static Context mContext;
    //默认的异常处理
    public static Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
    private List<Activity> activities=new ArrayList<>();
    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        //先取得默认的异常处理handler
        defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
    }
    {
        // wx42d306d5342119ab----ada0636d1d3433928e83bd90c7a393e2
        PlatformConfig.setWeixin("wx3c7dd92ef5aeeb64", "4b9a3e5dcdb65cf3bffb83da53346828");
    }


    public void addActivity(Activity activity){
     activities.add(activity);
    }
    public void clearActivity(){
        for (Activity activity : activities)
        {
            if (!activity.isFinishing()) {
                activity.finish();
            }

        }
        if (activities.size() == 0)
            activities.clear();
    }
}
